package com.kingint.web.portal.base.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kingint.common.unitedresult.K;
import com.kingint.mbg.bas.entity.BasHotel;
import com.kingint.web.portal.base.service.HotelService;
import com.kingint.web.sys.service.UmsMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @描述：酒店表控制类
 * @作者: wxh
 * @日期: 2020-12-21
 */
@RestController
@RequestMapping("/Hotel")
@Api(value = "BasHotelController", description = "酒店表")
@CrossOrigin
public class HotelController {

    @Autowired
    public HotelService basHotelService;
    @Autowired
    private UmsMemberService umsMemberService;



    @ApiOperation(value = "根据酒店表名称分页获取酒店表列表")
    @GetMapping("/list")
    public Object getList(){
        QueryWrapper<BasHotel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",umsMemberService.getUserHotel());
        List<BasHotel> list = basHotelService.list(queryWrapper);
        return K.ok().data(list);
    }

    @ApiOperation(value = "根据编号查询酒店表信息")
    @GetMapping("/{id}")
    @PreAuthorize("hasAuthority('basHotel:get')")
    public Object getItem(@PathVariable("id") Long id){
        BasHotel basHotel=basHotelService.getById(id);
        return K.ok().data(basHotel);
    }
}